<?php get_header() ?>

<div class="conteudo">
  <main>
    <section class="slide container">

      <?php motoPressSlider( "home-slider" ) ?>
    
    </section>
    <section class="servicos">
      <div class="container">

        <h1>Serviços</h1>

        <div class="row">
          <div class="col-md-4 col-sm-4 col-xs-12">
            
            <div class="servicos-item">
              <div class="servicos-img">
                <img src="<?php echo wp_get_attachment_url(get_theme_mod('set_servicos1'));?>" alt="">
              </div>
              <div class="servicos-desc">                             
                <h2><?php echo get_theme_mod('set_servicos1_titulo');?></h2>
                <p><?php echo get_theme_mod('set_servicos1_descricao');?></p>
              </div>
            </div>

          </div>
          <div class="col-md-4 col-sm-4 col-xs-12">
            
            <div class="servicos-item">
              <div class="servicos-img">
                <img src="<?php echo wp_get_attachment_url(get_theme_mod('set_servicos2'));?>" alt="">
              </div>
              <div class="servicos-desc">
                <h2><?php echo get_theme_mod('set_servicos2_titulo');?></h2>
                <p><?php echo get_theme_mod('set_servicos2_descricao');?></p>
              </div>
            </div>

          </div>
          <div class="col-md-4 col-sm-4 col-xs-12">
            
            <div class="servicos-item">
              <div class="servicos-img">
                <img src="<?php echo wp_get_attachment_url(get_theme_mod('set_servicos3'));?>" alt="">
              </div>
              <div class="servicos-desc">
                <h2><?php echo get_theme_mod('set_servicos3_titulo');?></h2>
                <p><?php echo get_theme_mod('set_servicos3_descricao');?></p>
              </div>
            </div>

          </div>          
        </div>

      </div>
    </section>

    <section class="meio container">
      <div class="row">
          <aside class="barra-lateral col-md-4">
            <?php get_sidebar('home');?>
          </aside>
          <!-- wp_query realizado na 3 aula - exemplo mais avançado 
                onde vai ter um post de cada categoria          
          -->
          <div class="noticias col-md-8">

            <div class="row">
            
              <?php

                $tamanho = 'col-md-12';
                $op_content = 'destaque';

                $itens = get_categories(array('include' => '5,8,9'));

                foreach($itens as $item) :

                  $args = array(
                    'category__in' => $item->cat_ID,
                    'posts_per_page' => 1
                  );

                $consulta = new WP_Query($args);

                if($consulta->have_posts()):
                  while($consulta->have_posts()):
                    $consulta->the_post();

                ?>
                  <div class="<?php echo $tamanho; ?>">
                    <?php 
                      get_template_part('content', $op_content);
                    ?>
                  </div>

                <?php
                  $tamanho = 'col-md-6';
                  $op_content = 'secundaria';
                                      
                  endwhile;            
                  wp_reset_postdata();
                endif;
                
                endforeach;
     
              ?>
       
            </div>

          </div>

          <!-- wp_query realizada nas primeiras duas aulas -->
          <div class="noticias col-md-8 col-md-offset-4">

            <div class="row">
              <!-- https://codex.wordpress.org/Class_Reference/WP_Query -->
              <?php 
                $destaque = new WP_Query('post_type=post&posts_per_page=1&cat=9,8');

                if($destaque->have_posts()) :
                  while($destaque->have_posts()) :
                    $destaque->the_post();

              ?>

                <div class="col-md-12">    
                  <!-- pegando o conteudo do arquivo content-destaque.php -->
                  <?php get_template_part('content','destaque') ;?>
                </div>

              <?php

                  endwhile;

                  // finalizando a estrutura do wp_query - podendo depois ter outras estruturas
                  wp_reset_postdata();

                endif;
              ?>



              <?php 
               // https://generatewp.com/wp_query/
                $args = array(
                  'post_type'       => array('post'),
                  'posts_per_page'  => 2,
                  'category__not_in' => array(5),
                  'category__in'    => array(8,9),
                  'offset'          => 1
                );
                // offset é para remover quantos posts iniciais,
                // para nao repetir a mesma noticia em destaque
                $secundarias = new WP_Query($args);

                if($secundarias->have_posts()) :
                  while($secundarias->have_posts()) :
                    $secundarias->the_post();

              ?>

                <div class="col-md-6">    
                  <!-- pegando o conteudo do arquivo content-secundarias.php -->
                  <?php get_template_part('content','secundaria') ;?>
                </div>

              <?php

                  endwhile;
                  // finalizando a estrutura do wp_query - podendo depois ter outras estruturas
                  wp_reset_postdata();

                endif;
              ?>
       
            </div>

          </div>
      </div>

    </section>

    <section class="mapa">
      <div class="ondeestamos">
        <h1>Onde Estamos?</h1>
      </div>
      <div class="google-maps">
        <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3652.7558011993387!2d-47.44803188254477!3d-23.470350296338566!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!4m3!3e0!4m0!4m0!5e1!3m2!1spt-BR!2sbr!4v1546751642995" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
      </div>
      <?php // gmwd_map( 1, 1); ?>  
    </section>

  </main>
</div>

<?php get_footer() ?>

